<template>
  <div class='login-qr-code'>
    <div class='scan-code'>
      <span>扫码登录</span>
    </div>
    <div class='qrcode'>
    </div>
    <div class='scan-app'>
      使用
      <span>网易云APP</span>
      扫码登录
    </div>
    <div class="login-mode-btn">
      <el-button size="mini" round @click="loginmore">选择其他登录方式</el-button>
    </div>
  </div>
</template>

<script>
import { qrcodeKeyVisb, createQrCode } from 'network/login.js'
export default {
  name: 'loginQrCode',
  data () {
    return {
      key: '',
      qrcode: true
    }
  },
  methods: {
    async qrcodeKeyVis () {
      const { data: res } = await qrcodeKeyVisb()
      if (res.code !== 200) {
        return this.$message.error('获取二维码失败')
      }
      this.key = res.unikey
      console.log(this.key)
      this.createQrCode(this.key)
    },
    async createQrCode (key) {
      const { data: res } = await createQrCode(key)
      console.log(res)
    //   this.qrcode = require(res.qrurl)
    //   console.log(this.qrcode)
    },
    loginmore () {
      this.qrcode = false
      this.$emit('more-method', this.qrcode)
    //   console.log(this.qrcode)
    }
  },
  created () {
    this.qrcodeKeyVis()
  }
}
</script>

<style lang="less">
  .login-qr-code {
    text-align: center;
  }
  .scan-code {
    font-size: 18px;
    font-weight: 800;
  }
  .scan-app {
    font-size: 12px;
    color: rgba(0, 0, 0, 0.4);
    span {
      color: #0c73c2;
      cursor: pointer;
    }
  }
  .login-mode-btn {
    margin-top: 20px;
  }
</style>
